export function insertionSort(targetArr, method = 'ASC'){
  const sorter = {
    DESC: ()=>{
      for(let i = 0; i < targetArr.length; i++){
        for(let j = 0; j < targetArr.length; j++){
          let container;
          if(j + 1 < targetArr.length){
            if(targetArr[j][1] < targetArr[j + 1][1]){
              container = targetArr[j + 1]
              targetArr[j + 1] = targetArr[j]
              targetArr[j] = container
            }else{
              continue
            }
          }
        }
      }
    },
    ASC: ()=>{
      for(let i = 0; i < targetArr.length; i++){
        for(let j = 0; j < targetArr.length; j++){
          let container;
          if(j + 1 < targetArr.length){
            if(targetArr[j][1] > targetArr[j + 1][1]){
              container = targetArr[j + 1]
              targetArr[j + 1] = targetArr[j]
              targetArr[j] = container
            }else{
              continue
            }
          }
        }
      }
    }
  }
  if(!Object.hasOwn(sorter, method)){
    return
  }
  sorter[method]()
}